﻿@using LaxCraft.Repositories;
@using LaxCraft.Domain;
@using LaxCraft.Helpers;
@{
    ViewBag.Title = "LaxCraft News";
}
<h2>LaxCraft News</h2>
@if (ViewBag.Admin) {
    <p>
        @Html.ActionLink("Create New", "Create")
    </p>
}
@foreach (var post in ViewBag.Posts) {
    <div class="postTitle">@post.Title</div>
    <div class="postBody">
        @post.GetHtml()
    </div>  
    <div class="postFooter">
        @string.Format("Posted by {0} on {1:g}", post.CreatedBy, post.CreatedOn);
        <br />
        @if (!string.IsNullOrEmpty(post.Tags)) {
             foreach (var tag in post.Tags.Split(",".ToCharArray())) {
            <span class="tag">@tag</span>
              }
            }
    </div>
  
                if (ViewBag.Admin) {
    <div class="adminAction">
        @Html.ActionLink("Edit", "Edit", new { id = post.Id })
        @Html.ActionLink("Delete", "Delete", new { id = post.Id }, new { rel = "nofollow" })
    </div>
                }
    }

@if (ViewBag.Admin) {
    <p>
        @Html.ActionLink("Create New", "Create")
    </p>
}